//==============================================================================
//3456789_123456789_123456789_123456789_123456789_123456789_123456789_123456789_
//                               (why all the numbers? I prefer 80-column text)
//
// CTransRot.cpp        Member function bodies for the CTransRot class
//==============================================================================

#include "CTransRot.h"  // the *ONLY* #include statement in this file!
                        // (if you need to #include another file, put
                        //  the #include statement in CTransRot.h, not here!)

CTransRot::~CTransRot(void)
//------------------------------------------------------------------------------
// Default destructor
{
}

CTransRot::CTransRot(void)
//------------------------------------------------------------------------------
// Default constructor
{
	reset();						// set all values to zero.
}

void CTransRot::reset(void)
//------------------------------------------------------------------------------
// Set all values to zero.
{
	x_pos = 0.0; y_pos = 0.0; z_pos = 0.0;
	x_rot = 0.0; y_rot = 0.0; z_rot = 0.0;
}

void CTransRot::applyMatrix(void)
//------------------------------------------------------------------------------
// Apply rotations, then translations to the coordinate axes.
// (Note OpenGL pre-multiplies matrices,
//   so commands appear to be in reverse order!)
{
	glTranslated(x_pos, y_pos, z_pos);	// OpenGL call to make a translate
									// matrix (see Blue Book) Uses 'd'
									// suffix to specify 'doubles' as arguments.
	glRotated(z_rot, 0.0, 0.0, 1.0);	// OpenGL call to make & apply a rotate
	glRotated(x_rot, 0.0, 1.0, 0.0);	// matrix; we want to rotate the coord
	glRotated(y_rot, 1.0, 0.0, 0.0);	// system FIRST in x, then y, then
										// z, BUT have to call them in
										// !!!REVERSE ORDER!!! because OpenGL
										//  glRotate, glTranslate each make
										// a matrix and then PRE_MULTIPLY the
										// existing 'active' matrix in storage
										// (e.g. the GL_MODELVIEW or
										// GL_PROJECTION, depending on which
										// one you selected with
										// 'glMatrixMode()'.
										// Note how we do all this in our
										// 'myReshape()' callback function.

}

